var animQueue: Array<Function> = [];

const req =
  (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame) ||
  function (f) {
    setTimeout(f, 60);
  };

export function mixins(curCls: any, obj: Record<string, Function>) {
	Object.keys(obj).forEach(key => {
		if (!curCls[key]) {
			curCls.prototype[key] = obj[key];
		}
	});
}
export function generateUUID() {
	return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
		/[xy]/g,
		function (c) {
			var r = (Math.random() * 16) | 0,
				v = c == "x" ? r : (r & 0x3) | 0x8;
			return v.toString(16);
		}
	);
}
export const $ = (id: string): HTMLElement => {
	return document.querySelector(id);
};
export function requestAnimFrame(callback: Function) {
	animQueue.push(callback);
	if (animQueue.length === 1) {
		req(function () {
			const queue = animQueue;
			animQueue = [];
			queue.forEach(function (cb) {
				cb();
			});
		});
	}
}
